"use strict";


const Joi = require('joi');
const Result = require("../basics/result");
const CheckUtil = require("../utils/check");
const BasicsCtl = require("../basics/clz/basectl");
const HomeImpl = require("../service/livecard");
const CardApi = require("../taobao/card");

class HomeCtl extends BasicsCtl {

  constructor(context) {
    super(context);
    this.homeImpl = new HomeImpl(this.cloud);
  }
  /**
   * 小部件查询
   */
  async selectLiveCards() {
    const rule = {
      session: Joi.string().required()
    }
    CheckUtil.validate(rule, this.params);
    return await this.homeImpl.quereyWidgetList(this.params);
  }
  /**
   * 小部件实例话
   */
  async editWedgit() {
    const rule = {
      session: Joi.string().required(),
      entity_id: Joi.string(),
      template_id: Joi.string().required(),
      template_version: Joi.string().required(),
      description: Joi.string()
    }
    CheckUtil.validate(rule, this.params);
    return await this.homeImpl.editWedgit(this.params);
  }

  // async selectLiveCards(){
  //   let {session,template_id} = this.params;
  //   return CardApi.selectList(this.cloud,session,{template_id});
  // }
}
module.exports = HomeCtl;